package spring.my.db.sharding.demo.config;

import org.springframework.web.bind.annotation.ControllerAdvice;

@ControllerAdvice
public class CommonConfigAdvice {

    /**
     * java8时间做参数处理方式(一)
     * @JsonDeserialize/ @JsonSerialize (二)
     * 在配置文件中添加
     *  spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
     *  spring.jackson.time-zone=GMT+8
     *
     * @param binder
     */
//    @InitBinder
//    protected void initBinder(WebDataBinder binder) {
//        binder.registerCustomEditor(LocalDate.class, new PropertyEditorSupport() {
//            @Override
//            public void setAsText(String text) throws IllegalArgumentException {
//                setValue(LocalDate.parse(text, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
//            }
//        });
//        binder.registerCustomEditor(LocalDateTime.class, new PropertyEditorSupport() {
//            @Override
//            public void setAsText(String text) throws IllegalArgumentException {
//                setValue(LocalDateTime.parse(text, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//            }
//        });
//        binder.registerCustomEditor(LocalTime.class, new PropertyEditorSupport() {
//            @Override
//            public void setAsText(String text) throws IllegalArgumentException {
//                setValue(LocalTime.parse(text, DateTimeFormatter.ofPattern("HH:mm:ss")));
//            }
//        });
//    }
}
